#! /bin/csh -f
#
# Aqua help script
# Call: qhelp [-p] item
# The -p option directs the output to the printer instead of to stdout
#

set print = 0
if ( $#argv != 0 ) then
	if ( "$argv[1]" == "-p" ) then
		set print = 1
		shift 
	endif
endif

set list = ( $argv[*] )
if ( $#list == 0 ) then
	set list = ( setup )
endif

set item = $list[1]
switch ( $item )
	case setup:
		echo "Current Aqua version:" $AQUAVERS". Root directory:" $aquaroot
		set fil = setup.txt
		breaksw
	case what:
	case qwhat:
	case aquawhat:
	case AquaWhat:
		set fil = AquaWhat.txt
		breaksw
	case how:
	case qhow:
	case aquahow:
	case AquaHow:
		set fil = AquaHow.txt
		breaksw
	case pseudo:
	case qpseudo:
	case aquapseudo:
	case AquaPseudo:
		set fil = AquaPseudo.txt
		breaksw
	case dist:
	case qdist:
	case aquadist:
	case AquaDist:
		set fil = AquaDist.txt
		breaksw
	case calc:
	case qcalc:
	case aquacalc:
	case AquaCalc:
		set fil = AquaCalc.txt
		breaksw
	case assign:
	case qassign:
	case aquaassign:
	case AquaAssign:
		set fil = AquaAssign.txt
		breaksw
	case redun:
	case qredun:
	case aquaredun:
	case AquaRedun:
		set fil = AquaRedun.txt
		breaksw
	case compl:
	case qcompl:
	case aquacompl:
	case AquaCompl:
		set fil = AquaCompl.txt
		breaksw
	case restraint_format:
	case format:
		set fil = restraint_format.txt
		breaksw
	default:
		set fil = $item.txt
		if ( ! -r $AQUADOCDIR/$fil ) then
		    echo "No help for item $item"
		    exit 1
		endif
endsw

set fil = $AQUADOCDIR/$fil
if ( ! -r $fil ) then
	echo "Error - file $fil does not exist"
	exit 1
endif

if ( $print ) then
	$AQUAHELPPRINT $fil
else
	$AQUAHELPLIST $fil
endif
